package com.example.riseofthedefender;

import android.graphics.PointF;
import android.util.FloatMath;

public class MyMath {
	public static float R2D = (float) (180.0f/Math.PI);
	public static float D2R = (float) (Math.PI/180.0f);
	
	public static float distance(PointF p1,PointF p2)
	{
		return FloatMath.sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
	}
	public static float angleR(PointF p1,PointF p2)
	{
		return (float)(Math.atan2(p2.y-p1.y,p2.x-p1.x));
	}
	public static float angleD(PointF p1,PointF p2)
	{
		return (float)(Math.atan2(p2.y-p1.y,p2.x-p1.x)*R2D);
	}
	public static float dot(PointF p1,PointF p2)
	{
		return p1.x * p2.x + p1.y * p2.y;
	}
	public static void NormVectorFromDegree(PointF ref,float degree)
	{
		ref.set(FloatMath.cos(degree*MyMath.D2R), FloatMath.sin(degree*MyMath.D2R));
	}
	public static void NormVectorFromRadian(PointF ref, float radian)
	{
		ref.set(FloatMath.cos(radian), FloatMath.sin(radian));
	}
	
	
	
}
